<template>
  <div class="home">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(item, index) in imgList" :key="index">
        <img :src="item.image" alt="" />
      </van-swipe-item>
    </van-swipe>
    <van-grid :column-num="3">
      <van-grid-item @click="jump(item)"
        v-for="(item, index) in gridList"
        :key="index"
        :icon="item.icon"
        :text="item.name"
      />
    </van-grid>
  </div>
</template>

<script>
// import { Lazyload } from 'vant';
export default {
  name: "Home",
  data() {
    return {
      imgList: [], // 轮播图的数据
      gridList: [],
    };
  },
  created() {
    this.$axios.get("https://locally.uieee.com/slides").then((res) => {
      //  console.log(res);
      this.imgList = res.data;
    });
    this.$axios.get("https://locally.uieee.com/categories").then((res) => {
      // console.log(res);
      this.gridList = res.data;
    });
  },
  methods: {
    jump(val){ // 点击九宫格触发的函数
      // console.log(val);
      this.$router.push(`/about/${val.id}`);
    }
  },
};
</script>
<style lang="scss">
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  text-align: center;
  img {
    width: 100%;
  }
}
</style>
